/**
 * Project: apollo-base-dal
 * 
 * File Created at 2017年2月20日
 * 
 * Copyright 2015-2016 dx.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DongXue software Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with dx.com.
 */
package com.dx.pf.dal.conf.rule;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;

import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

import com.dx.pf.dal.Logger;

/** 
* @ClassName: RuleConfigurationResolver 
* @Description: 规则配置解析
* @author wuzhenfang(wzfbj2008@163.com)
* @date 2017年2月20日 下午5:09:07 
* @version V1.0 
*/
public class RuleConfigurationResolver extends PathMatchingResourcePatternResolver {

	private final static Logger logger = Logger.getLogger(RuleConfigurationResolver.class);

	public static String ruleFilePath = "file:src/test/resources/";

	public static String ruleFileName = "datasourceRule.xml";

	private InputStream readloaderRuleStream;

	public RuleConfigurationResolver(String ruleFilePath) {
		try {
			Resource resource = getResource(ruleFilePath + ruleFileName);
			readloaderRuleStream = resource.getInputStream();
		} catch (MalformedURLException e) {
			logger.error("resouce资源加载失败，请查看datasourceRule.xml路径是否配置正确。", e);
		} catch (IOException e) {
			logger.error("从resouce中读取输出流失败", e);
		}
	}

	/**
	 * @return the readloaderRuleStream
	 */
	public InputStream getReadloaderRuleStream() {
		return readloaderRuleStream;
	}

	/**
	 * @param readloaderRuleStream the readloaderRuleStream to set
	 */
	public void setReadloaderRuleStream(InputStream readloaderRuleStream) {
		this.readloaderRuleStream = readloaderRuleStream;
	}
}
